<?php
/* SVN FILE: $Id$ */

/**
 * Enter description here ....
 *
 * @filesource
 * @copyright    Copyright (c) 2006, .
 * @link
 * @package
 * @subpackage
 * @since
 * @version      $Revision$
 * @modifiedby   $LastChangedBy$
 * @lastmodified $Date$
 * @license      http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * Controller :: Offerings
 *
 * Enter description here...
 *
 * @package
 * @subpackage
 * @since
 */
class OfferingsController extends AppController
{
    var $name = 'Offerings';
	var $paginate = array('limit' => 25, 'page' => 1);
	var $helpers = array('Html','Ajax','Javascript','Time','Paginator');
	var $components = array('RequestHandler');
	
function index($conditions=null) {
	
		$institutions = $this->Offering->Institution->find('list');
		$institutions[0]='All Programs';
		ksort($institutions);
		$this->set('institutions', $institutions);
	
		$semesters = $this->Offering->Semester->find('list');
		$semesters[0] = 'All Semesters';
		ksort($semesters);
		$this->set('semesters', $semesters);

		$offeringtypes = $this->Offering->OfferingType->find('list');
		$offeringtypes[0] = 'All Types';
		$offeringtypes[] = 'Cancelled';
		ksort($offeringtypes);
		$this->set('offeringTypes', $offeringtypes);
	
		$years = $this->Offering->find('list',array('fields'=>'Offering.year','group'=>'Offering.year'));
		$this->set('years',$years);
	
		if($conditions==null) {
	
		$params = array(
			'conditions' => array('Offering.year' => 2008,
								  'Semester.semester' => 'Fall'),
			'order' => array('Institution.institution_abbr','OfferingType.offering_type')
		);
	
		} else {
	
		}
	
		$this->Offering->contain('Institution.institution_abbr',
								'Course.course',
								'Course.course_title',
								'Course.Plugin',
								'Semester.id',
								'Semester.semester',
								'OfferingType.id',
								'OfferingType.offering_type',
								'Enrollment.id',
								'Enrollment.Person.id',
								'Enrollment.Role.icon',
								'Enrollment.Person.Role.role');
	
	
		$this->set('data', $this->Offering->find('all',$params));
	
		
	
	}
	
	function view($id)
	{
			$this->Offering->contain('Course.id',
			'Course.course',
			'Course.course_title',
			'Institution.id',
			'Institution.institution_abbr',
			'Semester.id','Semester.semester',
			'DevSemester.id',
			'DevSemester.semester',
			'OfferingType.offering_type',
			'Status.percent',
			'Status.status',
			'Task.id',
			'Task.TaskType.task_type',
			'Task.Status.percent',
			'Task.Status.status',
			'Enrollment.id',
			'Enrollment.Person',
			'Enrollment.Role.icon',
			'Enrollment.Person.Role.role',
			'Enrollment.Person.LmsRole.lms_role',
			'Enrollment.course_section',
			'OfferingComment.comment',
			'OfferingComment.created',
			'OfferingComment.Person',
			'OfferingComment.Person.Role.role',
			'OfferingComment.course_support',
			'OfferingLog.id',
			'OfferingLog.Person',
			'OfferingLog.EventType.event_type',
			'OfferingLog.created');
	
			$this->set('data', $this->Offering->read());

	}
	
	

}

?>